package com.example.asus.yuejian_10;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by Wolfh on 2017/5/8.
 */

public abstract class BaseListAdapter extends RecyclerView.Adapter {

    private List data;
    protected Context context;
    private LayoutInflater layoutInflater;


    public BaseListAdapter(Context context, List list){
        this.context = context;
        this.data = list;
        this.layoutInflater = layoutInflater.from(context);
    }

    abstract protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType);

    abstract protected void onBindVH(RecyclerView.ViewHolder holder, int position , List data);

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        return onCreateVH(parent , layoutInflater , viewType);
    }


    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        onBindVH(holder , position , data);
    }


    @Override
    public int getItemCount() {
        return data.size();
    }
}
